<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>验证汽车</title>
		 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
         <meta name="apple-mobile-web-app-capable" content="yes">
         <meta content="yes" name="apple-touch-fullscreen">
         <meta name="apple-mobile-web-app-status-bar-style" content="black">  
         <script src="js/add_js.js"></script>
	</head>
	<body>
		<!--nav-->
        <nav class="bar bar-tab">
             <a class="tab-item external active" href="home.html">我的</a>
             <a class="tab-item external" href="order.html">定单</a>
             <a class="tab-item external" href="carRental.html">出租</a>
             <a class="tab-item external" href="rentalCar.html">租车</a>
             <div class="clear"></div>
        </nav>
        <!--nav-->
		<div class="page content">
			
      	    <header class="bar bar-nav">
               <a  class="button button-link button-nav pull-right active">添加车辆</a>
               <a href="carManger.html" class="button button-link button-nav pull-right">返回车辆管理 </a>
           </header>
            <!--选车型-->
           <div class="get-car-hold"></div>
      	   <div class="get-car">
      	      <div class="get-car-list get-car-lista"><span class="active" name='abcd'>ABCDE</span><span>HJKLMN</span><span>HJKLMN</span><span>OPQRST</span><span>UVWXYZ</span><div class="clear"></div></div>
      	      <input class="get-car-other-box" type="text" placeholder="点击输入车辆品牌及型号" >
      	      <div class="get-car-other-btn">确认</div>
      	      <div class="get-car-list get-car-listb"><span class="active" id="0">宝马</span><span>保时捷</span><span>宾利</span><span>布加迪</span><span class="get-car-other">其他</span><div class="clear"></div></div>
      	      <div class="get-car-list get-car-listc"><span class="get-car-other">其他</span><div class="clear"></div></div>
      	      <div class="get-car-list get-car-listd"><span class="get-car-other">其他</span><div class="clear"></div></div>
      	   </div>
      	   <!--选车型-->
      		<div class="login-list checkCar-list">
      			<ul>
      				<li><input class="c-border login-list-qr" type="text" placeholder="品牌车型" name="car" title="" ></li>
      				<li><input class="c-border login-list-qr" type="text" placeholder="车牌号码" name="c_number" ></li>
      			    <li><input class="c-border login-list-qr" type="text" placeholder="交强险保单号" name="insurance_num"> </li>
      			    <li><input class="c-border login-list-qr" type="text" placeholder="商业险保单号" name="busin_num"> </li>
      			    <li><div class="c-border login-list-yz register-list-yz check-car-upload-img img-xsz-z" name='0'><img src="img/icon/upload.png">上传行驶证正本照片</div></li>
      			    <li><div class="c-border login-list-yz register-list-yz check-car-upload-img img-xsz-f" name='0'><img src="img/icon/upload.png">上传行驶证副本照片</div></li>
      			    <li><div class="c-border login-list-yz register-list-yz check-car-upload-img img-jqx" name='0'><img  src="img/icon/upload.png">上传交强险保单照片</div></li>
      			    <li><div class="c-border login-list-yz register-list-yz check-car-upload-img img-syx" name='0'><img  src="img/icon/upload.png">上传商业险保单照片</div></li>
      			    <li class="register-list-sq" style="margin-bottom: 8px;padding-right: 10px;">拍摄时尽量避免反光和阴影过重</li>
      			    <li class="login-list-b"><a class="bottn" id="zc" style="float: right;">提交</a><div class="clear"></div></li> 
      			 </ul>
      	   </div>
      	   <div class="chek-car-add-img"></div>
      	<script>
      
      		$(document).ready(function(){
      			if(my.checkLogin()){
      			 my.scollToggleBar()
      			//my.checkLogin()
      			//key=my.get_key(sessionStorage.token)
      	    	 key=my.get_key(my.getCookie('token'))
      			//表单选中效果切换
//    			$('.login-list input').focus(function(){
//    				$(this).css('color','#fff')
//    			})
//    			$('.login-list input').blur(function(){
//    				$(this).css('color','#5926BF')
//    			})
      			//注册登陆点击效果
      			$('.login-list-b a').click(function(){
      				$(this).css({'color':'#fff','backgroundColor':'#5926BF'})
      			})
      			//选择品牌
      			$('[name=car]').click(function(e){
      				e.preventDefault()
      				$('span[name=abcd]').trigger('click')
      				$('.get-car-hold').show(300)
      				$('.get-car').show(300)
      			})
      			$('.get-car-hold').click(function(){
      				$(this).hide()
      				$('.get-car').hide()
      			})
      			var list=[
		      {"band":"bmw",
		       "name":"宝马",
			   "Id":"1",
			   "xi":[
				           {  "name":"车系1",
				      	      "车系id":"id",
				      	      "carlist":[{"carid":"carid","carname":"carname1"},{"carid":"carid","carname":"carname1"}]
				          },
				           {  "name":"车系2",
				      	      "车系id":"id",
				      	      "carlist":[{"carid":"carid","carname":"carname2"},{"carid":"carid","carname":"carname2"}]
				            }
				     ]
		     },
		     {"band":"bl",
		       "name":"宝来",
			   "Id":"1",
			   "xi":[
				           {  "name":"车系3",
				      	      "车系id":"id",
				      	      "carlist":[{"车辆id":"carid","carname":"carname3"},{"carid":"carid","carname":"carname3"}]
				            }
				     ]
		      }
	        ]
	         $('.get-car-lista span').click(function(){
		       $('.get-car-lista span').removeClass('active')
		       $(this).addClass('active')
		       var name=$(this).attr('name')
		       $('.get-car-listb span').not('.get-car-other').remove()
		       $('.get-car-listb').show()
		       $('.get-car-listc,.get-car-listd,.get-car-other-box,.get-car-other-btn').hide()
		       for(i=0;i<list.length;i++){
			      if(name.match(list[i].band.substr(0,1))){
				      var html="<span id='"+i+"'>"+list[i].name+"</span>"
				     $('.get-car-listb').prepend(html)
		          }
		        }
		        $('.get-car-listb span').not('.get-car-other').click(function(){
		 	              $('.get-car-listb span').removeClass('active')
		                  $(this).addClass('active')
		                  $('.get-car-listc span').not('.get-car-other').remove()
		                  $('.get-car-listc').show()
		                  $('.get-car-listd span').not('.get-car-other').remove()
		                  $('.get-car-listd').hide()
		                  var j=$(this).attr('id')
		                  for(i=0;i<list[j].xi.length;i++){
		                  	   var html="<span id='"+j+"' name='"+i+"'>"+list[j].xi[i].name+"</span>"
		                     $('.get-car-listc').prepend(html)
		                   }
		                   $('.get-car-listc span').not('.get-car-other').click(function(){
		                   	                     $('.get-car-listc span').removeClass('active')
		                                         $(this).addClass('active')
		                                         $('.get-car-listd span').not('.get-car-other').remove()
		                                         $('.get-car-listd').show()
		                                         var j=$(this).attr('id')
		                                         var w=$(this).attr('name')
		                                         for(i=0;i<list[j].xi[w].carlist.length;i++){
		                                         	var html="<span id='"+list[j].xi[w].carlist[i].carid+"'>"+list[j].xi[w].carlist[i].carname+"</span>"
		                                            $('.get-car-listd').prepend(html)
		                                          }
		                                          $('.get-car-listd span').not('.get-car-other').click(function(){
                	                                $('[name=car]').val($(this).text())
                	                                $('[name=car]').attr('title',$(this).attr('id'))
                	                                $('.get-car').hide()
      				                                $('.get-car-hold').hide()
                                                  })
	                    })
	                })
                })	
               $('.get-car-listb span').not('.get-car-other').click(function(){
		                  $('.get-car-listc span').remove()
		                  $('.get-car-listc').show()
		                  $('.get-car-listd span').remove()
		                  var j=$(this).attr('id')
		                  for(i=0;i<list[j].xi.length;i++){
		                  	   var html="<span id='"+j+"' name='"+i+"'>"+list[j].xi[i].name+"</span>"
		                     $('.get-car-listc').prepend(html)
		                   }
               })
                $('.get-car-other').click(function(){
               	   $('.get-car-listb,.get-car-listc,.get-car-listd').hide()
               	   $('.get-car-other-box,.get-car-other-btn').show()
               	   
                })
                $('.get-car-other-btn').click(function(){
                	$('[name=car]').val($('.get-car-other-box').val())
//              	$('[name=car]').attr('title',$(this).attr('id'))
                	$('.get-car').hide()
      				$('.get-car-hold').hide()
                })
      			//上传图片
      			$('.img-xsz-z').click(function(){
      				 var list={"id":".img-xsz-z","text":"行驶证正面"}
      			         list=JSON.stringify(list)
      				 ad.native_get_photo(list)
      			})
      			$('.img-xsz-f').click(function(){
      				 var list={"id":".img-xsz-f","text":"行驶证反面"}
      			         list=JSON.stringify(list)
      				 ad.native_get_photo(list)
      			})
      			$('.img-jqx').click(function(){
      				 var list={"id":".img-jqx","text":"交强险保单"}
      			         list=JSON.stringify(list)
      				 ad.native_get_photo(list)
      			})
      			$('.img-syx').click(function(){
      				 var list={"id":".img-syx","text":"商业险保单"}
      			         list=JSON.stringify(list)
      				 ad.native_get_photo(list)
      			})
      			//提交
      			$('#zc').click(function(){
      			
      				for(i=0;i<$('.checkCar-list :text').length;i++){
      					if($('.checkCar-list :text').eq(i).val()==''){
      						$.toast('请填写完整')
      						$('.checkCar-list :text').eq(i).focus()
      						return false
      					}
      				}
      				if($('.img-xsz-z').attr('name')=='0'){$.toast('请上传行驶证正本照片'); return false}
      				if($('.img-xsz-f').attr('name')=='0'){$.toast('请上传行驶证副本照片'); return false}
      				if($('.img-jqx').attr('name')=='0'){$.toast('请上传交强险保单照片'); return false}
      				if($('.img-syx').attr('name')=='0'){$.toast('请上传商业险保单照片'); return false}
      				$.showIndicator()
      				var info={
      						//'u_userid':sessionStorage.id,
      						'u_userid':my.getCookie('id'),
      						'c_number':$('[name=c_number]').val(),
      						'insurance_num':$('[name=insurance_num]').val(),
      						'busin_num':$('[name=busin_num]').val(),
      						'veh_first_img':$('.img-xsz-z').attr('name'),
      						'veh_second_img':$('.img-xsz-f').attr('name'),
      						'insurance_img':$('.img-jqx').attr('name'),
      						'busin_img':$('.img-syx').attr('name'),
      					}
    					info=JSON.stringify(info)
                        info=my.cryptoASEencrypt(info,key).toString()
      				$.ajax({
      						type:"post",
      						url:"http://192.168.1.10:8082/index.php?r=userabout%2Fuser%2Fusercarsmanage",
      						data:{
      							'api_value':info
      						},
      						async:true,
      						error:function(){
      							$.hideIndicator()
      							$.toast("提交失败，请重试..");
      						},
      						success:function(data){
      							if(data.match("err_code")!=null){
      								$.hideIndicator()
      								switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									    my.tokenExpire()
      									   break;
      									default:
      									   $.alert(JSON.parse(data).err_msg);
      								}
                                         
      							}else{
      								    $.hideIndicator()
      								    //data=JSON.parse(my.cryptoASEdencrypt(data,key))
        								$.toast("提交成功，等待审核");
      							        $.router.loadPage("home.html");
      							}
      						},
      				});
      						
      			})
      			}
      		})
      		
      	</script>
      </div>
	</body>
</html>
